﻿using System;
using System.Collections.Generic;
using System.Drawing;

namespace AppRPG.PhysObject
{
	public class CollisionManager
	{
		private readonly List<PhysObject> _physObjects;
		
		private readonly Player _player;

		public CollisionManager(Player player)
		{
            _player = player;

			_physObjects = new List<PhysObject>();
		}
		
		public bool GetPlayerIsIntersectAnyOne()
		{
			Rectangle playerRect = new Rectangle(_player.GetPosition(), 
			                                     _player.GetDimension());
			
			foreach (PhysObject physObject in _physObjects)
			{
				Rectangle physObjectRect = new Rectangle(physObject.GetPosition(), 
				                                         physObject.GetDimension());
				
				if (playerRect.IntersectsWith(physObjectRect))
				{
					return false;
				}
			}
			
			return true;
		}
	}
}
